<?php
error_reporting(E_ALL); // great for debug and development, you can remove this two lines for production app
ini_set('display_errors', 'On');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>




<?php

function am47($href)
{		
					$a = '
						webpage = require("webpage");
page = webpage.create();
page.onResourceRequested = function(request, net) {

  	if (request.url.indexOf(\'http://tunghoanh.com\') === 0){
  	//	net.abort();
  		//console.log(request.url);
	}else{
		//console.log(request.url);
		//console.log(request.url);
	
	}
}

page.settings.loadImages=false;
page.onConsoleMessage = function(msg) {
    console.log(msg);
};

page.onResourceError = function(resourceError) {
    page.reason = resourceError.errorString;
    console.log(page.reason);
    page.reason_url = resourceError.url;
    console.log(page.reason_url);
};

			page.onLoadFinished = function() {
					page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", function() {
							page.evaluate(function() {
										$.ajax({
			    						url : \'http://anime47.com/download/download.php\',
			    						type:\'POST\',
			    						async: false,
			    						cache: false,
			    						data: {
										epid:\'105884\'
										},
		    						success: function(data){
											
			    							console.log(data);
			    						},
										error: function(jqxhr,textStatus,errorThrown){
				                       	
				                        } //End of log error
		
			    					});// End ajax
			
			    			
		    					}); //End of try evaluation
								phantom.exit();
						}); //end page.include js
			}//End page.onloadfinished

	page.open(\'http://anime47.com/download/download.php\', function(status) {
	if(status === "success") {
		    						//return next(status, url, file);
							
   		//phantom.exit();
    }//Status==successel
	else{
		
	}
});';
				file_put_contents('am.js', $a);
				exec('phantomjs am.js', $a, $b);

				$count = count($a);
				echo $count;
				$content_html = $a[$count - 1];
				echo $content_html;
			
} 
//am47('http://anime47.com/xem-phim-mahouka-koukou-no-rettousei-ep-25/107548.html');

echo file_get_contents("http://anime47.com/download/download.php?url=VjJ4YWIyUXkzK1hsMytibFpZWWtoQ1ZsWXdhMitKOCtSbFp6VjIxR1YwMXJXbmxVVlZKaFZGZFdWV0pJYUZoVzErMDE0VkcxNFUxZFgzK2tobFIyeHBZa1ZaZUZkVVMzK0ZSMStsRjVWRzU4K2FsNytHV2s1Wlc0KzUrWDMrMytGYWMxUlVVbXhTVjIrWldWV3hTUjFReVJuSldhbHBWMytWWktVMVJYY3pGV1ZrNVZWbXM1YUdKNCtkRDcrV1JsWjMrWW1zd2QwOVdWbFJYUm41K2hWajUrb1EwMHhVbGhqUlZwUFZtdEc3K2xrd1duZFcxK2tWNFYxUkdXbUpVVm5WVTErVnA5K1VqRjgrV1dGR1ZsZGlSVzh4VjFaYWFtVkdWbFpQVm1SWVZrVndVMVpzVm1GajErVloxWTBVNTMrMkY2UmxoV1IzUnJVMjFXYzJKMiszK2xWNytSa3A5K1drUjUrZUc3K1dWbFZWYXpWMytVajYrd2QxWkdXbDcrMytiVkYzMytsWldhR1ZyYzIrOWFWM2hHMysxMis5UFE9PQ==");
?>
</body>
</html>
